<template>
	<view class="app">
		<tui-tabs :tabs="tabs" isFixed :currentTab="currentTab" selectedColor="#5677fc" sliderBgColor="#5677fc" @change="change" itemWidth="50%"></tui-tabs>

		<view class="coupon-list">
			<view class="coupon-item" v-for="(item, index) in list" :key="index">
				<view class="coupon">
					<image v-if="currentTab == 0" src="/static/images/index/img_fuwuquan_blue_3x.png" class="coupon-img"></image>

					<image v-if="currentTab == 0" src="/static/icons/spinWin.png" class="coupon-img-icon"></image>

					<image v-if="currentTab == 1" src="/static/images/index/img_fuwuquan_pink_3x.png" class="coupon-img"></image>

					<image v-if="currentTab == 1" src="/static/icons/spinWin1.png" class="coupon-img-icon"></image>
					<view v-if="currentTab == 0" class="left-tit-box">
						<view class="tit">{{ item.spinWinName }}</view>
						<view class="term">转盘所需积分：{{ item.spinWinNeedIntegral }}</view>
					</view>
					<view v-else class="left-tit-box">
						<view class="tit">{{ item.spinWinName }}</view>
						<view class="term">转盘：{{ item.raffleTicketName }}</view>
					</view>
					<view class="right-detail" @tap="spread(item)">
						<text class="detail-txt huxi">立即抽奖</text>
						<image src="/static/images/index/icon_next_3x.png" class="arrow huxi"></image>
					</view>
				</view>
			</view>
		</view>

		<tui-no-data imgUrl="/static/images/toast/img_nodata.png" v-if="!loading && !list.length">暂无记录</tui-no-data>
		<view v-if="!loading && list.length" class="loading-more"><text class="loading-more-text">~~没有更多了~~</text></view>
		<Loading type="img" v-if="loading"></Loading>
	</view>
</template>

<script>
import { spinWinList } from '@/service/spinwin.js';
export default {
	data() {
		return {
			tabs: [
				{
					name: '积分抽奖'
				},
				{
					name: '星级券抽奖'
				}
			],

			currentTab: 0,
			loading: true,
			list: []
		};
	},
	async onLoad() {
		this.getList();
	},
	async onPullDownRefresh() {
		this.getList();
		uni.stopPullDownRefresh();
	},
	methods: {
		change({ index }) {
			this.currentTab = index;
			this.list = [];
			this.getList();
		},
		spread(item) {
			uni.navigateTo(
				{
					url: '/pages/game/turntable/index'
				},
				{
					...item
				}
			);
		},
		async getList() {
			try {
				this.loading = true;
				this.list = await spinWinList({ spinWinType: this.currentTab == 0 ? 'integral' : 'raffleTicket' });
			} finally {
				this.loading = false;
			}
		}
	}
};
</script>

<style scoped lang="scss">
.app {
	padding-top: 100upx;
}
.coupon-list {
	width: 100%;
	padding: 54rpx 30rpx 54upx 70rpx;
	padding-top: 0upx;
	box-sizing: border-box;
}

.coupon-item {
	margin-top: 20rpx;
	width: 100%;
	box-shadow: 0 8rpx 10rpx -8rpx #eaeef1;
	border-radius: 2rpx;
}

.coupon {
	height: 160rpx;
	position: relative;
	display: flex;
	align-items: center;
}

.coupon-img {
	width: 100%;
	height: 160rpx;
	position: absolute;
	left: 0;
	top: 0;
	z-index: 0;
}
.coupon-img-icon {
	width: 80upx;
	height: 80upx;
	position: absolute;
	left: -30upx;
	top: 40upx;
	z-index: 0;
}

.left-tit-box {
	width: 414rpx;
	padding-left: 75rpx;
	box-sizing: border-box;
	z-index: 10;
}

.tit {
	width: 290rpx;
	font-size: 30rpx;
	color: #333;
	line-height: 42rpx;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.term {
	width: 228rpx;
	font-size: 24rpx;
	color: #999;
	line-height: 24rpx;
	padding-top: 7rpx;
	white-space: nowrap;
}

.right-detail {
	width: 236rpx;
	text-align: center;
	height: 160rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
}

.detail-txt {
	font-size: 34rpx;
	color: #fff;
	padding-right: 12rpx;
}

.arrow {
	width: 16rpx;
	height: 24rpx;
	transition: all 0.15s ease;
}

.spread {
	width: 24rpx;
	height: 16rpx;
}

.qrcode {
	width: 260rpx;
	height: 260rpx;
	margin: 45rpx auto 43rpx auto;
}

.hidden-box {
	padding: 35rpx 40rpx 27rpx 40rpx;
	box-sizing: border-box;
	color: #333;
	border-top: 1rpx solid #eaeef1;
	background: #fff;
}

.code-tit {
	font-size: 28rpx;
	line-height: 28rpx;
}

.code-num {
	font-size: 30rpx;
	line-height: 30rpx;
	padding-top: 23rpx;
	font-weight: bold;
}

.qrcode-box {
	width: 100%;
	border-bottom: 1rpx dashed #eaeef1;
	margin-bottom: 6rpx;
}

.list-item {
	height: 90rpx;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 28rpx;
}

.list-item::after {
	left: 0;
}

.item-tit {
	color: #666;
}

.item-con {
	color: #333;
}

.explain {
	font-size: 28rpx;
	line-height: 28rpx;
	color: #666;
	padding: 33rpx 0 25rpx 0;
}

.explain-text {
	font-size: 28rpx;
	line-height: 41rpx;
	color: #333;
}

.none {
	width: 100%;
	position: fixed;
	text-align: center;
	font-size: 30rpx;
	color: #ccc;
	top: 49%;
}
.tui-rotate_90 {
	transform: rotate(90deg);
}
.pink {
	color: #e478ff;
}
</style>
